/*
 *  AppDataSegment.h
 *  TubeTruck
 *
 *  Created by Aeturnum on 6/6/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#include <vector>
#include <assert.h>
#include <exception>

#include "TubeTruckTypes.h"
#include "Serializable.h"
#include "serialization.h"
#include "unserialization.h" 
#include "smartalloc_wrap.h"
#include "Encryptable.h"
#include "RSA.h"
#include "util.h"

namespace TTP {
   class AppDataSegment : public Serializable {
   protected:
      ack_num mAckNumber;
      std::vector<byte> mData;
   public:
      
      AppDataSegment();
      AppDataSegment(ack_num, std::vector<byte>&);
      AppDataSegment(const AppDataSegment& o);
      ~AppDataSegment();
      
      unsigned short getDataLength() const;
      ack_num getAckNumber() const;
      std::vector<byte> getData() const;
      int getSize() const;
      
      void setAckNumber(ack_num);
      void setData(std::vector<byte>&);
      void appendData(std::vector<byte>&);
      
      // inherited
      void fromVec(std::vector<byte>::const_iterator &vit, 
       const std::vector<byte>::const_iterator &end);
      void toVec(std::vector<byte> &vec) const;
   };
}
